﻿namespace _抽象工厂模式
{
    internal class Program
    {
        static void Main(string[] args)
        {
            User user = new User();
            IFactory factory = new SqlserverFactory();
            IUser user1 = factory.CreateUser();
            user1.Insert(user);
            user1.GetUser(1);

            IDepartment department = factory.CreateDepartment();
            department.Insert(new Department());
            department.GetDepartment(1);
            Console.ReadKey();
        }
    }
    class Department
    {

    }
    class User
    {
        public int id { get; set; }
        public string Name { get; set; }
    }
    interface IDepartment
    {
        void Insert(Department department);
        Department GetDepartment(int id);
    }
    interface IUser
    {
        void Insert(User user);
        User GetUser(int id);
    }
    class SqlserverDepartment : IDepartment
    {
        public Department GetDepartment(int id)
        {
            return null;
        }

        public void Insert(Department department)
        {
            Console.WriteLine();
        }
    }
    class AccessDepartment : IDepartment
    {
        public Department GetDepartment(int id)
        {
            return null;
        }

        public void Insert(Department department)
        {
            Console.WriteLine("123");
        }
    }
    class SqlserverUser : IUser
    {
        public User GetUser(int id)
        {
            return null;
        }

        public void Insert(User user)
        {
            Console.WriteLine(user.id);
        }
    }
    class AccessUser : IUser
    {
        public User GetUser(int id)
        {
            return null;
        }

        public void Insert(User user)
        {
            Console.WriteLine();
        }
    }
    interface IFactory
    {
        IUser CreateUser();
        IDepartment CreateDepartment();
    }
    class SqlserverFactory : IFactory
    {
        public IDepartment CreateDepartment()
        {
            return new SqlserverDepartment();
        }

        public IUser CreateUser()
        {
            return new SqlserverUser();
        }
    }
    class AccessFactory : IFactory
    {
        public IDepartment CreateDepartment()
        {
            return new AccessDepartment();
        }

        public IUser CreateUser()
        {
            return new AccessUser();
        }
    }
}
